package com.company.netease2020;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Test202007 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        Map<Integer,Integer> count = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int t = sc.nextInt();
            count.put(t,count.getOrDefault(t,0) + 1);
        }
        for (int i = 0; i < m; i++) {
            int c = sc.nextInt();
            if(count.get(c) == null){
                System.out.println(0);
            }else{
                System.out.println(count.get(c));
            }

        }
    }
}
